<template>
  <section class="feature">
    <div class="feature-content">
      <div class="feature-content-item" @click="contentClick(item.id,item.categoryName)"
           v-for="item in nexusHomeList" :key="item.id">
        <h2 v-html="item.logoUrl">

        </h2>
        <div>
          <h1> {{ item.categoryName }} </h1>
        </div>
      </div>
    </div>
  </section>
</template>

<script setup lang="ts">
import {useRouter} from "vue-router";
import {getNexusHome} from "@/api/nexusSphere/nexusHome.js";
import {onMounted, ref} from "vue";
import {useLibraryPage} from '@/stores/libraryPage'

interface nexusHome {
  id: number;
  categoryName: string;
  logoUrl: string
}


const router = useRouter();

const libraryPage = useLibraryPage();


const nexusHomeList = ref<nexusHome[]>([]);
const getList = async () => {
  const res = await getNexusHome();
  nexusHomeList.value = res.data.data;
};

const contentClick = (id: number, categoryName: string) => {
  const url = `/libraryPage/${id}?title=${encodeURIComponent(categoryName)}`;
  window.open(url, '_blank');
};

onMounted(() => {
  getList();
});
</script>

<style scoped lang="scss">
.feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: white;
  text-align: center;
  height: 500px;
  padding: 2rem 20rem;

  .feature-content {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    // width: 800px;

    .feature-content-item {
      display: flex;
      // background-color: #f2f6fc;
      width: 150px;
      height: 200px;
      // margin: 20px 80px;
      border-radius: 15px;
      overflow: hidden;
      padding: 0 80px;
      justify-content: flex-start;
      align-items: center;
      flex-direction: column;
      align-items: center;

      &:hover {
        animation: hoverEffect 0.6s forwards;
      }

      h1 {
        //  margin-left: 40px;
        text-overflow: ellipsis; /* 当文本溢出时显示省略号 */
        white-space: nowrap; /* 不换行 */
        overflow: hidden; /* 隐藏溢出的内容 */
        font-weight: 300;
      }

      h2 {
        height: 80px;
        width: 80px;
      }

      span {
        margin-left: 50px;
        width: 300px;
        text-overflow: ellipsis; /* 当文本溢出时显示省略号 */
        white-space: nowrap; /* 不换行 */
        overflow: hidden; /* 隐藏溢出的内容 */
        display: inline-block;
      }
    }

    @keyframes hoverEffect {
      0% {
        transform: scale(1);
        opacity: 1;
        box-shadow: none;
      }
      50% {
        transform: scale(1.1);
        opacity: 0.9;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
      }
      100% {
        transform: scale(1.1);
        opacity: 1;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
      }
    }
  }
}

.feature-title {
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

.feature-item {
  display: inline - block;
  width: 30%;
  margin: 1rem;
}

.feature-icon {
  height: 4rem;
}

.feature-text {
  margin-top: 0.5rem;
}
</style>
